/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package backupit.core.io;

import backupit.core.dirbackup.DirBackup;
import backupit.core.BackupList;
import java.beans.XMLDecoder;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author dbotelho
 */
public class LoadBackupList implements Runnable{
    
    private BackupList backupList;
    private XMLDecoder decoder;

    public LoadBackupList(String fileName) throws FileNotFoundException{
        super();
        this.decoder = new XMLDecoder(new BufferedInputStream(
                new FileInputStream(fileName)));
    }

    public void run() {
        setBackupList((BackupList) decoder.readObject());
        decoder.close();
    }

    public BackupList getBackupList() {
        return backupList;
    }

    public void setBackupList(BackupList backupList) {
        this.backupList = backupList;
    }
    /*public static void main(String[] args){
        try {
            LoadBackupList loader = new LoadBackupList("/home/dbotelho/backuplist.xml");
            Thread t = new Thread(loader);
            t.start();
            t.join();
            BackupList backupList = loader.getBackupList();
            for(DirBackup b: backupList)
                System.out.println(b.getName());
            
        } catch (InterruptedException ex) {
            Logger.getLogger(LoadBackupList.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(SaveBackupList.class.getName()).log(Level.SEVERE, null, ex);
        }
    }*/
}
